include(`foreach.m4')
dnl
include(`common.m4')
dnl
define(`TOHWM4_list_subs', `dnl

  subroutine cmlStart$1(xf, TOHWM4_dummyarglist($2))

    type(xmlf_t), intent(inout) :: xf
dnl
m4_foreach(`x', `$2', `TOHWM4_dummyargdecl(x)')
dnl

#ifndef DUMMYLIB
    call xml_NewElement(xf, "$1")

dnl
m4_foreach(`x', `$2', TOHWM4_dummyarguse(x))
dnl
#endif

  end subroutine cmlStart$1

  subroutine cmlEnd$1(xf)
    type(xmlf_t), intent(inout) :: xf
#ifndef DUMMYLIB
    call xml_EndElement(xf, "$1")
#endif
  end subroutine cmlEnd$1

')dnl
dnl
dnl
! This file is AUTOGENERATED!!!!
! Do not edit this file; edit m_wcml_metadata.m4 and regenerate.
!

module m_wcml_lists

  use FoX_wxml, only: xmlf_t

#ifndef DUMMYLIB
  use FoX_common, only: str
  use FoX_wxml, only: xml_NewElement, xml_EndElement
  use FoX_wxml, only: xml_AddAttribute
#endif

  implicit none
  private

  public :: cmlStartMetadataList
  public :: cmlEndMetadataList

  public :: cmlStartPropertyList
  public :: cmlEndPropertyList

  public :: cmlStartParameterList
  public :: cmlEndParameterList

  public :: cmlStartBandList
  public :: cmlEndBandList

  public :: cmlStartKpointList
  public :: cmlEndKpointList

  public :: cmlStartModule
  public :: cmlEndModule

  public :: cmlStartStep
  public :: cmlEndStep

contains

TOHWM4_list_subs(`metadataList', (`dictRef', `convention', `title', `id', `name', `role'))

TOHWM4_list_subs(`propertyList', (dictRef, convention, title, id, ref, role))

TOHWM4_list_subs(`parameterList', (dictRef, convention, title, id, ref, role))

TOHWM4_list_subs(`bandList', (dictRef, convention, title, id, ref, role))
!FIXME what attributes
TOHWM4_list_subs(`kpointList', (dictRef, convention, title, id, ref, role))
!FIXME what attributes
TOHWM4_list_subs(`module', (serial, title, id, convention, dictRef, role))

  subroutine cmlStartStep(xf, type, index, id, title, convention)
    type(xmlf_t), intent(inout) :: xf
    character(len=*), intent(in), optional :: type
    character(len=*), intent(in), optional :: id
    integer, intent(in), optional :: index
    character(len=*), intent(in), optional :: title
    character(len=*), intent(in), optional :: convention

#ifndef DUMMYLIB
    if (present(index)) then
      call cmlStartModule(xf=xf, id=id, title=title, convention=convention, &
        dictRef=type, role='step', serial=str(index))
    else
      call cmlStartModule(xf=xf, id=id, title=title, convention=convention, &
        dictRef=type, role='step')
    endif
#endif
    
  end subroutine cmlStartStep


  subroutine cmlEndStep(xf)
    type(xmlf_t), intent(inout) :: xf
#ifndef DUMMYLIB
    call xml_EndElement(xf, 'module')
#endif
  end subroutine cmlEndStep


end module m_wcml_lists
